import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { DailyItem } from "../item/DailyItem";
import { InvalidationType } from "../../../../../fl/core/InvalidationType";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
type int = number;
//class DailyListBody
    
    export  class DailyListBody /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._bodyList = new GBox();
            this._bodyList.direction = GBoxDirection.VERTICAL;
            this._bodyList.verticalGap = 2;
            addChild(this._bodyList);
            return;
        }

        public addItem(arg1: DailyItem): void
        {
            this._bodyList.addChild(arg1);
            return;
        }

        public getItemAt(arg1: int): DailyItem
        {
            if (this._bodyList.numChildren > arg1 && arg1 >= 0) 
            {
                return this._bodyList.getChildAt(arg1) as DailyItem;
            }
            return null;
        }

        public getItemByType(arg1: int): DailyItem
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._bodyList.numChildren) 
            {
                loc1 = this._bodyList.getChildAt(loc2) as DailyItem;
                if (loc1 && loc1.info && loc1.info.type == arg1) 
                {
                    return loc1;
                }
                ++loc2;
            }
            return null;
        }

        public get length(): int
        {
            return this._bodyList.numChildren;
        }

        public get selectIndex(): int
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._bodyList.numChildren) 
            {
                loc1 = this._bodyList.getChildAt(loc2) as DailyItem;
                if (loc1 && loc1.isSelected) 
                {
                    return loc2;
                }
                ++loc2;
            }
            return 0;
        }

        public redraw(): void
        {
            this._bodyList.layChildChanged = true;
            this._bodyList.invalidate(InvalidationType.ALL);
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._bodyList.numChildren > 0) 
            {
                loc1 = this._bodyList.removeChildAt(0) as DailyItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1);
            }
            return;
        }

        public /* override */ get height(): number
        {
            var loc1=0;
            var loc3=null;
            var loc2=this._bodyList.numChildren;
            var loc4=0;
            while (loc1 < loc2) 
            {
                loc3 = this._bodyList.getChildAt(loc1) as DailyItem;
                loc4 = loc4 + (loc3.height + this._bodyList.verticalGap);
                ++loc1;
            }
            return loc4;
        }

        protected /* var */_bodyList: GBox;
    }
